const app = getApp()
import {
  globalApi,
  myApi
} from "../../../api/index";

Page({
  data: {
    IMGBASEURL: app.globalData.IMGBASEURL,
    showL: false,
    Key:"",
  },
  goPage(e) {
    wx.navigateTo({
      url: e.currentTarget.dataset['index'],
    })
  },
  goHome() {
    wx.switchTab({
      url: '/pages/ai/index',
    })
  },
  getHong() {
    const token = wx.getStorageSync('token')
    if (token) {
      console.log('this.data.key',this.data.key);
      console.log('2222',wx.getStorageSync('packetKey'));
            myApi.invivtereward({
              Key:wx.getStorageSync('packetKey')
            }).then((res)=>{
                 if(res.StatusCode == 200){
                  wx.navigateTo({
                    url: '/pages/my/welfareTask/invitationFriend/index?isDraw=true',
                  })
                 }else{
                  this.setData({
                    showL: true
                  })
                 }
             
            })
    } else {
      wx.navigateTo({
        url:'/pages/login/index?backPageUrl=pages/my/Inviting-red-envelopes/index'
      })
    }

  },
  onClose() {
    this.setData({
      showH: false
    })
  },
  onLoad(options) {
    console.log('2222',options.key);
    if(options.key){
      wx.setStorageSync('packetKey', options.key)
      this.setData({
        key:options.key
      })
    }
  
  },


  onReady() {

  },

  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})